<template>
    <el-table :data="menuInfo" border style="width: 100%;" ref="multipleTable">
        <el-table-column prop="id" label="ID" width="200">
        </el-table-column>
        <el-table-column prop="title" label="菜单名称">
        </el-table-column>
        <el-table-column prop="name" label="英文名称">
        </el-table-column>
        <el-table-column prop="icon" label="图标">
        </el-table-column>
        <el-table-column prop="sort" label="排序" width="100">
        </el-table-column>
        <el-table-column prop="hidden" label="隐藏" width="100">
        </el-table-column>
        <el-table-column prop="status" label="状态" width="100">
            <template slot-scope="scope">
                <el-tag type="success" v-show="scope.row.status == 1">正常</el-tag>
                <el-tag type="danger" v-show="scope.row.status == 2">禁用</el-tag>
            </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="140">
            <template slot-scope="scope">
                <el-button type="text" size="small">编辑</el-button>
                <el-button type="text" size="small" @click="showDelete(scope.row)">删除</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
export default {
    name: "MenuItem",
    props: ['menuInfo'],
    data() {
        return {
            // 展示删除页面
            deleteVisible: false,
            // 删除的信息
            deleteInfo: {},
        }
    },
    methods: {
        // 查看
        handleClick(data) {
            console.log(data)
        },
        // 展示删除
        showDelete(data) {
            this.deleteInfo = data
            this.deleteVisible = true
        },
        // 删除
        async subDelete() {
            let res = await this.$store.dispatch('deleteTableInfo', this.deleteInfo.id)
            if (res.success) {
                // 重新渲染数据
                this.$emit('getTableData')
                this.$message.success(res.message)
            }
            else this.$message.error(res.message)
        }
    },
    computed: {
        tableData() {
            return this.$store.state.table.tableData
        }
    }
}
</script>

<style scope>
.el-collapse-item__header {
    font-size: 1rem;
    font-weight: 550;
    color: #726464;
}

/* 设置滚动条宽度和高度 */
.el-table__body-wrapper::-webkit-scrollbar {
    width: 8px;
    /* 横向滚动条 */
    height: 8px;
    /* 纵向滚动条 必写 */
}

/* 设置滚动条样式 */
.el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #dde;
    border-radius: 3px;
}
</style>